#ifndef __MACRO_POKER_PLAY_H__
#define __MACRO_POKER_PLAY_H__

#include <vector>
#include <string>
#include <map>
#include "card.h"

namespace poker
{
class Play;
class PlayRegister;

typedef std::unique_ptr<Play> (*PlayGenerator)();

// 每次出的一手牌的类型
std::map<std::string, PlayGenerator> g_playFactory = {};

#define REGISTER_PLAY_TYPE(NAME, TYPE) do { \
    std::unique_ptr<TYPE> TYPE##_GENERATOR() {
        return std::make_unique<TYPE>();
    }
    PlayRegister g_##TYPE_##Generator(#NAME, TYPE##_GENERATOR);
} while(0)

class PlayRegister
{
public:
    PlayRegister(const std::string& name, PlayGenerator generator) {
        g_playFactory.insert(std::make_pair(name, generator));
    }
    ~PlayRegister();
}

/**
 * @brief 定义一手牌
 * 
 */
class Play
{
public:
    /**
     * @brief Construct a new Play object
     * 
     * @param points 指定一手牌的点数，创建一手牌对象
     */
    Play(const std::vector<Card>& cards);
    ~Play();

private:
    // 保存每一手牌的点数
    std::vector<Card> cards_{};
    // 这一手牌的名字
    std::string name_{};

}; // class Play

} // namespace poker




#endif // __MACRO_POKER_PLAY_H__